
declare const WindowManager: any;
export class SkerInfo {
    static showPrintWindow: boolean = false;
    static msgWindow: AutoJs.FloatyWindow
    static create() {
        importClass('android.view.WindowManager');
        importClass("android.view.Gravity");
        importClass("android.graphics.PixelFormat");
        this.showPrintWindow = true;
        this.msgWindow = floaty.window(`<vertical id="msgLayout" padding="5" margin="0" bg="#000000">
        <text id="msg" text="暂无信息" textColor="#ffffff"/>
    </vertical>`);
        ui.run(() => {
            const parentParent = this.msgWindow.msgLayout.parent.parent.parent;
            let params = parentParent.layoutParams || {};
            if (params.flags == 16777736) {
                params.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
            } else if (params.flags == 16777752) {
                params.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
            }
            const windowManager = context.getSystemService(context.WINDOW_SERVICE);
            windowManager.updateViewLayout(parentParent, params);
            this.msgWindow.setPosition(0, 0)
        })
    }

    static init() {
        this.create()
        events.on("log", msg => {
            ui.run(() => {
                this.msgWindow.msg.setText(msg);
            })
        })
        events.on('info', () => {
            ui.run(() => {
                if (this.showPrintWindow) {
                    this.msgWindow.close()
                    this.showPrintWindow = false;
                } else {
                    this.create()
                }
            })
        })
    }
}